package com.roam.service.impl;

import com.roam.VO.SearchPageSceneVO;
import com.roam.VO.SelectPagePopularSceneVO;
import com.roam.VO.TourPlanVO;
import com.roam.entity.scene.Scene;
import com.roam.mapper.SceneInfoMapper;
import com.roam.mapper.SearchPageMapper;
import com.roam.mapper.SelectPageMapper;
import com.roam.service.SearchPageService;
import com.roam.service.SelectPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SearchPageServiceImpl implements SearchPageService {

    @Autowired
    private SearchPageMapper searchPageMapper;


    @Override
    public List<SearchPageSceneVO> getSearchedScenes(String content) {
        List<SearchPageSceneVO> searchPageSceneVOS=new ArrayList<>();
        List<TourPlanVO> searchedScenes=searchPageMapper.getSearchedScenes(content);
        for (TourPlanVO scene : searchedScenes) {
            SearchPageSceneVO searchPageSceneVO = SearchPageSceneVO.builder()
                    .sceneID(scene.getId())
                    .city(scene.getCity())
                    .scene(scene.getName())
                    .location(scene.getPosition())
                    .url(scene.getImg())
                    .build();
            searchPageSceneVOS.add(searchPageSceneVO);
        }
        return searchPageSceneVOS;
    }
}
